package cn.wolfcode.crm.web.controller;


import cn.wolfcode.crm.domain.DictionaryBill;
import cn.wolfcode.crm.service.IDictionaryBillService;
import cn.wolfcode.crm.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("dictionaryBill")
public class DictionaryBillController {
    @Autowired
    private IDictionaryBillService dictionaryBillService;


    //查询所有字典目录
    @RequestMapping("query")
    @ResponseBody
    public Object selectAll() {
        //将数据转换成json格式
        List<DictionaryBill> dictionaryBills = dictionaryBillService.selectAll();

        return dictionaryBills;
    }

    //通过sn查询
    //查询所有字典目录
    @RequestMapping("selectBySn")
    @ResponseBody
    public Object selectBySn(String sn) {
        //将数据转换成json格式
        List<DictionaryBill> dictionaryBills = dictionaryBillService.selectBySn(sn);

        return dictionaryBills;
    }



    @RequestMapping("view")

    public String list1(Model model, Long id) {

        return "/dictionaryBill/list";
    }




    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate( DictionaryBill entity) {
       dictionaryBillService.saveOrUpdate(entity);

        return new JSONResult();
    }



    @RequestMapping("delete")
    @ResponseBody
    public Object delete( Long id) {
       dictionaryBillService.deleteByPrimaryKey(id);

        return new JSONResult();
    }


}
